<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .active {
            color: red;
        }
        .line {
            font-style: italic;
        }
    </style>
</head>
<body>
<div id="app">
    <h2 class="otherClass" :class="{active: isActive,line: isBolder}">{{message}}</h2>
    <!-- 这里写成getClasses是不会找到方法的-->
    <h3 class="otherClass" :class="getClasses()">{{message}}</h3>
    <!-- 原本是@click="btnClick()，左右括号省略了"-->
    <button @click="btnClick">切换</button>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
    const app = new Vue({
        el: '#app',
        data: {
            message: 'simplelu',
            isActive: true,
            isBolder: true
        },
        methods: {
            btnClick: function () {
                this.isActive = !this.isActive
            },
            getClasses: function () {
                return {active: this.isActive,line: this.isBolder }
            }
        }
    })
</script>
</body>
</html>